using System;
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Metadata;

namespace Sino.CapacityCloud.Repositories.Migrations
{
    public partial class BusinessTables : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AspNetRoles",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    ConcurrencyStamp = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    NormalizedName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ApplicationRole", x => x.Id);
                });
            migrationBuilder.CreateTable(
                name: "Bank",
                columns: table => new
                {
                    BankId = table.Column<string>(nullable: false),
                    Code = table.Column<string>(nullable: true),
                    LogoKey = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Bank", x => x.BankId);
                });
            migrationBuilder.CreateTable(
                name: "Carrier",
                columns: table => new
                {
                    CarrierId = table.Column<string>(nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Type = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Carrier", x => x.CarrierId);
                });
            migrationBuilder.CreateTable(
                name: "Cost",
                columns: table => new
                {
                    CostId = table.Column<string>(nullable: false),
                    ApplyTime = table.Column<long>(nullable: false),
                    AuditState = table.Column<string>(nullable: true),
                    CarrierOrderId = table.Column<string>(nullable: true),
                    CostPrice = table.Column<double>(nullable: false),
                    CostType = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Cost", x => x.CostId);
                });
            migrationBuilder.CreateTable(
                name: "PaidCost",
                columns: table => new
                {
                    PaidCostId = table.Column<string>(nullable: false),
                    ApplyTime = table.Column<DateTime>(nullable: false),
                    CostPrice = table.Column<decimal>(nullable: false),
                    CostType = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    QuotationId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PaidCost", x => x.PaidCostId);
                });
            migrationBuilder.CreateTable(
                name: "PayableCost",
                columns: table => new
                {
                    PayableCostId = table.Column<string>(nullable: false),
                    CarrierOrderId = table.Column<string>(nullable: true),
                    CostType = table.Column<int>(nullable: false),
                    OrderId = table.Column<string>(nullable: true),
                    PaymentDate = table.Column<DateTime>(nullable: false),
                    PaymentMethod = table.Column<int>(nullable: false),
                    Price = table.Column<decimal>(nullable: false),
                    Progress = table.Column<int>(nullable: false),
                    Remarks = table.Column<string>(nullable: true),
                    SettleType = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PayableCost", x => x.PayableCostId);
                });
            migrationBuilder.CreateTable(
                name: "SmsCode",
                columns: table => new
                {
                    SmsId = table.Column<string>(nullable: false),
                    ApproveTime = table.Column<DateTime>(nullable: true),
                    Code = table.Column<string>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    FailureTime = table.Column<DateTime>(nullable: false),
                    PhoneNumber = table.Column<string>(nullable: true),
                    Remarks = table.Column<string>(nullable: true),
                    StatusCode = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SmsCode", x => x.SmsId);
                });
            migrationBuilder.CreateTable(
                name: "TransportLinkage",
                columns: table => new
                {
                    TransportLinkageId = table.Column<string>(nullable: false),
                    DestinationLocation_Longitude = table.Column<double>(nullable: false),
                    DestinationLocation_Latitude = table.Column<double>(nullable: false),
                    DestinationPlaceCode = table.Column<string>(nullable: true),
                    DestinationPlaceName = table.Column<string>(nullable: true),
                    Remarks = table.Column<string>(nullable: true),
                    StartingPlaceCode = table.Column<string>(nullable: true),
                    StartingPlaceLocation_Latitude = table.Column<double>(nullable: false),
                    StartingPlaceLocation_Longitude = table.Column<double>(nullable: false),
                    StartingPlaceName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TransportLinkage", x => x.TransportLinkageId);
                });
            migrationBuilder.CreateTable(
                name: "WebApiCredential",
                columns: table => new
                {
                    WebApiCredentialId = table.Column<string>(nullable: false),
                    AppKey = table.Column<string>(nullable: true),
                    AppSecrect = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WebApiCredential", x => x.WebApiCredentialId);
                });
            migrationBuilder.CreateTable(
                name: "AspNetRoleClaims",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ClaimType = table.Column<string>(nullable: true),
                    ClaimValue = table.Column<string>(nullable: true),
                    RoleId = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IdentityRoleClaim<string>", x => x.Id);
                    table.ForeignKey(
                        name: "FK_IdentityRoleClaim<string>_ApplicationRole_RoleId",
                        column: x => x.RoleId,
                        principalTable: "AspNetRoles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });
            migrationBuilder.CreateTable(
                name: "Car",
                columns: table => new
                {
                    CarId = table.Column<string>(nullable: false),
                    AssignmentOfLoad = table.Column<double>(nullable: false),
                    CarriageType = table.Column<int>(nullable: false),
                    CarrierId = table.Column<string>(nullable: true),
                    CertificationStatus = table.Column<int>(nullable: false),
                    Code = table.Column<string>(nullable: true),
                    Date = table.Column<DateTime>(nullable: true),
                    Length = table.Column<int>(nullable: false),
                    Origin = table.Column<string>(nullable: true),
                    Rank = table.Column<string>(nullable: true),
                    Remarks = table.Column<string>(nullable: true),
                    State = table.Column<string>(nullable: true),
                    Type = table.Column<int>(nullable: false),
                    VehicleLicenseKey = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Car", x => x.CarId);
                    table.ForeignKey(
                        name: "FK_Car_Carrier_CarrierId",
                        column: x => x.CarrierId,
                        principalTable: "Carrier",
                        principalColumn: "CarrierId",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "AccidentPicture",
                columns: table => new
                {
                    AccidentPictureId = table.Column<string>(nullable: false),
                    AccidentPictureKey = table.Column<string>(nullable: true),
                    CostId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AccidentPicture", x => x.AccidentPictureId);
                    table.ForeignKey(
                        name: "FK_AccidentPicture_Cost_CostId",
                        column: x => x.CostId,
                        principalTable: "Cost",
                        principalColumn: "CostId",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "AspNetUsers",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    AccessFailedCount = table.Column<int>(nullable: false),
                    Address = table.Column<string>(nullable: true),
                    AvatarKey = table.Column<string>(nullable: true),
                    CarId = table.Column<string>(nullable: true),
                    CarriageType = table.Column<int>(nullable: false),
                    CarrierCarrierId = table.Column<string>(nullable: true),
                    CertificatePhotoCertificationState = table.Column<int>(nullable: false),
                    CertificatePhotoKey = table.Column<string>(nullable: true),
                    ConcurrencyStamp = table.Column<string>(nullable: true),
                    DrivingLicenseKey = table.Column<string>(nullable: true),
                    DrivingLicenseKeyCertificationState = table.Column<int>(nullable: false),
                    Email = table.Column<string>(nullable: true),
                    EmailConfirmed = table.Column<bool>(nullable: false),
                    FailureTime = table.Column<long>(nullable: false),
                    IdentityCardCertificationState = table.Column<int>(nullable: false),
                    IdentityCardKey = table.Column<string>(nullable: true),
                    LockoutEnabled = table.Column<bool>(nullable: false),
                    LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
                    NormalizedEmail = table.Column<string>(nullable: true),
                    NormalizedUserName = table.Column<string>(nullable: true),
                    PasswordHash = table.Column<string>(nullable: true),
                    PhoneNumber = table.Column<string>(nullable: true),
                    PhoneNumberConfirmed = table.Column<bool>(nullable: false),
                    Profile = table.Column<string>(nullable: true),
                    RealName = table.Column<string>(nullable: true),
                    SecurityStamp = table.Column<string>(nullable: true),
                    Token = table.Column<string>(nullable: true),
                    TwoFactorEnabled = table.Column<bool>(nullable: false),
                    UserName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ApplicationUser", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ApplicationUser_Car_CarId",
                        column: x => x.CarId,
                        principalTable: "Car",
                        principalColumn: "CarId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ApplicationUser_Carrier_CarrierCarrierId",
                        column: x => x.CarrierCarrierId,
                        principalTable: "Carrier",
                        principalColumn: "CarrierId",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "AspNetUserClaims",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    ClaimType = table.Column<string>(nullable: true),
                    ClaimValue = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IdentityUserClaim<string>", x => x.Id);
                    table.ForeignKey(
                        name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });
            migrationBuilder.CreateTable(
                name: "AspNetUserLogins",
                columns: table => new
                {
                    LoginProvider = table.Column<string>(nullable: false),
                    ProviderKey = table.Column<string>(nullable: false),
                    ProviderDisplayName = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IdentityUserLogin<string>", x => new { x.LoginProvider, x.ProviderKey });
                    table.ForeignKey(
                        name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });
            migrationBuilder.CreateTable(
                name: "AspNetUserRoles",
                columns: table => new
                {
                    UserId = table.Column<string>(nullable: false),
                    RoleId = table.Column<string>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IdentityUserRole<string>", x => new { x.UserId, x.RoleId });
                    table.ForeignKey(
                        name: "FK_IdentityUserRole<string>_ApplicationRole_RoleId",
                        column: x => x.RoleId,
                        principalTable: "AspNetRoles",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });
            migrationBuilder.CreateTable(
                name: "BankCard",
                columns: table => new
                {
                    BankCardId = table.Column<string>(nullable: false),
                    BankId = table.Column<string>(nullable: true),
                    Holder = table.Column<string>(nullable: true),
                    Number = table.Column<string>(nullable: true),
                    Type = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BankCard", x => x.BankCardId);
                    table.UniqueConstraint("AK_BankCard_Number", x => x.Number);
                    table.ForeignKey(
                        name: "FK_BankCard_Bank_BankId",
                        column: x => x.BankId,
                        principalTable: "Bank",
                        principalColumn: "BankId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_BankCard_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "CommonTransportLinkage",
                columns: table => new
                {
                    CommonTransportLinkageId = table.Column<string>(nullable: false),
                    Remarks = table.Column<string>(nullable: true),
                    TransportLinkageId = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommonTransportLinkage", x => x.CommonTransportLinkageId);
                    table.ForeignKey(
                        name: "FK_CommonTransportLinkage_TransportLinkage_TransportLinkageId",
                        column: x => x.TransportLinkageId,
                        principalTable: "TransportLinkage",
                        principalColumn: "TransportLinkageId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_CommonTransportLinkage_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "ConfirmedOrder",
                columns: table => new
                {
                    ConfirmedOrderId = table.Column<string>(nullable: false),
                    Amount = table.Column<double>(nullable: false),
                    AmountUnit = table.Column<string>(nullable: true),
                    ArrivalTime = table.Column<DateTime>(nullable: false),
                    CarLength = table.Column<string>(nullable: true),
                    CarrierOrderId = table.Column<string>(nullable: true),
                    Category = table.Column<string>(nullable: true),
                    ContactChatId = table.Column<string>(nullable: true),
                    ContactName = table.Column<string>(nullable: true),
                    ContactPhoneNumber = table.Column<string>(nullable: true),
                    DeliveryTime = table.Column<DateTime>(nullable: false),
                    Emergency = table.Column<double>(nullable: false),
                    GrabComment = table.Column<string>(nullable: true),
                    IsFocus = table.Column<bool>(nullable: false),
                    ParentConfirmedOrderId = table.Column<string>(nullable: true),
                    Price = table.Column<string>(nullable: true),
                    Remarks = table.Column<string>(nullable: true),
                    State = table.Column<int>(nullable: false),
                    TransportLinkageId = table.Column<string>(nullable: true),
                    Type = table.Column<int>(nullable: false),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ConfirmedOrder", x => x.ConfirmedOrderId);
                    table.ForeignKey(
                        name: "FK_ConfirmedOrder_ConfirmedOrder_ParentConfirmedOrderId",
                        column: x => x.ParentConfirmedOrderId,
                        principalTable: "ConfirmedOrder",
                        principalColumn: "ConfirmedOrderId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ConfirmedOrder_TransportLinkage_TransportLinkageId",
                        column: x => x.TransportLinkageId,
                        principalTable: "TransportLinkage",
                        principalColumn: "TransportLinkageId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_ConfirmedOrder_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "FavouriteTransportLinkage",
                columns: table => new
                {
                    FavouriteTransportLinkageId = table.Column<string>(nullable: false),
                    Remarks = table.Column<string>(nullable: true),
                    TransportLinkageId = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FavouriteTransportLinkage", x => x.FavouriteTransportLinkageId);
                    table.ForeignKey(
                        name: "FK_FavouriteTransportLinkage_TransportLinkage_TransportLinkageId",
                        column: x => x.TransportLinkageId,
                        principalTable: "TransportLinkage",
                        principalColumn: "TransportLinkageId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_FavouriteTransportLinkage_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "FriendRelationship",
                columns: table => new
                {
                    FriendRelationshipId = table.Column<string>(nullable: false),
                    FriendId = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FriendRelationship", x => x.FriendRelationshipId);
                    table.ForeignKey(
                        name: "FK_FriendRelationship_ApplicationUser_FriendId",
                        column: x => x.FriendId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_FriendRelationship_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "Location",
                columns: table => new
                {
                    LocationId = table.Column<string>(nullable: false),
                    Address = table.Column<string>(nullable: true),
                    CarId = table.Column<string>(nullable: true),
                    Latitude = table.Column<double>(nullable: false),
                    Longitude = table.Column<double>(nullable: false),
                    Time = table.Column<DateTime>(nullable: false),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Location", x => x.LocationId);
                    table.ForeignKey(
                        name: "FK_Location_Car_CarId",
                        column: x => x.CarId,
                        principalTable: "Car",
                        principalColumn: "CarId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Location_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "Order",
                columns: table => new
                {
                    OrderId = table.Column<string>(nullable: false),
                    Amount = table.Column<double>(nullable: false),
                    AmountUnit = table.Column<string>(nullable: true),
                    ArrivalTime = table.Column<DateTime>(nullable: false),
                    CarLength = table.Column<string>(nullable: true),
                    CarrierOrderId = table.Column<string>(nullable: true),
                    Category = table.Column<string>(nullable: true),
                    ContactChatId = table.Column<string>(nullable: true),
                    ContactName = table.Column<string>(nullable: true),
                    ContactPhoneNumber = table.Column<string>(nullable: true),
                    DeliveryTime = table.Column<DateTime>(nullable: false),
                    Emergency = table.Column<double>(nullable: false),
                    GrabComment = table.Column<string>(nullable: true),
                    IsFocus = table.Column<bool>(nullable: false),
                    ParentOrderId = table.Column<string>(nullable: true),
                    Price = table.Column<string>(nullable: true),
                    Remarks = table.Column<string>(nullable: true),
                    State = table.Column<int>(nullable: false),
                    TransportLinkageId = table.Column<string>(nullable: true),
                    Type = table.Column<int>(nullable: false),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Order", x => x.OrderId);
                    table.ForeignKey(
                        name: "FK_Order_Order_ParentOrderId",
                        column: x => x.ParentOrderId,
                        principalTable: "Order",
                        principalColumn: "OrderId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Order_TransportLinkage_TransportLinkageId",
                        column: x => x.TransportLinkageId,
                        principalTable: "TransportLinkage",
                        principalColumn: "TransportLinkageId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Order_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "TransportLinkageDispacherTask",
                columns: table => new
                {
                    TransportLinkageDispacherTaskId = table.Column<string>(nullable: false),
                    CarId = table.Column<string>(nullable: true),
                    Dispacher = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TransportLinkageDispacherTask", x => x.TransportLinkageDispacherTaskId);
                    table.ForeignKey(
                        name: "FK_TransportLinkageDispacherTask_Car_CarId",
                        column: x => x.CarId,
                        principalTable: "Car",
                        principalColumn: "CarId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_TransportLinkageDispacherTask_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "UserPointRecord",
                columns: table => new
                {
                    UserPointRecordId = table.Column<string>(nullable: false),
                    AvailablePoints = table.Column<double>(nullable: true),
                    Remarks = table.Column<string>(nullable: true),
                    TotalPoints = table.Column<double>(nullable: true),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserPointRecord", x => x.UserPointRecordId);
                    table.ForeignKey(
                        name: "FK_UserPointRecord_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "RatingRecord",
                columns: table => new
                {
                    RatingRecordId = table.Column<string>(nullable: false),
                    Appraiser = table.Column<string>(nullable: true),
                    Attitude = table.Column<float>(nullable: false),
                    CarId = table.Column<string>(nullable: true),
                    CarrierOrderId = table.Column<string>(nullable: true),
                    ContractNumber = table.Column<string>(nullable: true),
                    Driver = table.Column<string>(nullable: true),
                    Evaluation = table.Column<string>(nullable: true),
                    Integrity = table.Column<float>(nullable: false),
                    OrderId = table.Column<string>(nullable: true),
                    PhoneNumber = table.Column<string>(nullable: true),
                    Pricing = table.Column<float>(nullable: false),
                    Remarks = table.Column<string>(nullable: true),
                    Time = table.Column<DateTime>(nullable: false),
                    Timeliness = table.Column<float>(nullable: false),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RatingRecord", x => x.RatingRecordId);
                    table.ForeignKey(
                        name: "FK_RatingRecord_Car_CarId",
                        column: x => x.CarId,
                        principalTable: "Car",
                        principalColumn: "CarId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_RatingRecord_ConfirmedOrder_OrderId",
                        column: x => x.OrderId,
                        principalTable: "ConfirmedOrder",
                        principalColumn: "ConfirmedOrderId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_RatingRecord_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "UserFocusedConfirmedOrder",
                columns: table => new
                {
                    UserFocusedOrderId = table.Column<string>(nullable: false),
                    ConfirmedOrderId = table.Column<string>(nullable: true),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserFocusedConfirmedOrder", x => x.UserFocusedOrderId);
                    table.ForeignKey(
                        name: "FK_UserFocusedConfirmedOrder_ConfirmedOrder_ConfirmedOrderId",
                        column: x => x.ConfirmedOrderId,
                        principalTable: "ConfirmedOrder",
                        principalColumn: "ConfirmedOrderId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_UserFocusedConfirmedOrder_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateTable(
                name: "Quotation",
                columns: table => new
                {
                    QuotationId = table.Column<string>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    OrderId = table.Column<string>(nullable: true),
                    Price = table.Column<double>(nullable: false),
                    Remarks = table.Column<string>(nullable: true),
                    Time = table.Column<DateTime>(nullable: false),
                    Unit = table.Column<int>(nullable: false),
                    UserId = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Quotation", x => x.QuotationId);
                    table.ForeignKey(
                        name: "FK_Quotation_Order_OrderId",
                        column: x => x.OrderId,
                        principalTable: "Order",
                        principalColumn: "OrderId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Quotation_ApplicationUser_UserId",
                        column: x => x.UserId,
                        principalTable: "AspNetUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });
            migrationBuilder.CreateIndex(
                name: "RoleNameIndex",
                table: "AspNetRoles",
                column: "NormalizedName");
            migrationBuilder.CreateIndex(
                name: "EmailIndex",
                table: "AspNetUsers",
                column: "NormalizedEmail");
            migrationBuilder.CreateIndex(
                name: "UserNameIndex",
                table: "AspNetUsers",
                column: "NormalizedUserName");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable("AspNetRoleClaims");
            migrationBuilder.DropTable("AspNetUserClaims");
            migrationBuilder.DropTable("AspNetUserLogins");
            migrationBuilder.DropTable("AspNetUserRoles");
            migrationBuilder.DropTable("AccidentPicture");
            migrationBuilder.DropTable("BankCard");
            migrationBuilder.DropTable("CommonTransportLinkage");
            migrationBuilder.DropTable("FavouriteTransportLinkage");
            migrationBuilder.DropTable("FriendRelationship");
            migrationBuilder.DropTable("Location");
            migrationBuilder.DropTable("PaidCost");
            migrationBuilder.DropTable("PayableCost");
            migrationBuilder.DropTable("Quotation");
            migrationBuilder.DropTable("RatingRecord");
            migrationBuilder.DropTable("SmsCode");
            migrationBuilder.DropTable("TransportLinkageDispacherTask");
            migrationBuilder.DropTable("UserFocusedConfirmedOrder");
            migrationBuilder.DropTable("UserPointRecord");
            migrationBuilder.DropTable("WebApiCredential");
            migrationBuilder.DropTable("AspNetRoles");
            migrationBuilder.DropTable("Cost");
            migrationBuilder.DropTable("Bank");
            migrationBuilder.DropTable("Order");
            migrationBuilder.DropTable("ConfirmedOrder");
            migrationBuilder.DropTable("TransportLinkage");
            migrationBuilder.DropTable("AspNetUsers");
            migrationBuilder.DropTable("Car");
            migrationBuilder.DropTable("Carrier");
        }
    }
}
